![]() |
PATH![]() |
![]() ![]() |
If you use a reference of the form alias nameString , AppleScript creates an alias for the file--that is, a representation of the file, much like an alias icon on the desktop, that identifies the file no matter where it is located. AppleScript attempts to locate the file whenever you compile the script--that is, whenever you modify the script and then attempt to check its syntax, save it, or run it.
AppleScript treats an alias like a value that can be stored in a variable and passed around within a script. You don't need to use the A Reference To operator. For example, this script first saves an alias in the variable fileRef , then uses the variable in a Tell statement that opens the file.
set fileRef to alias "Hard Disk:June Sales"
tell application "AppleWorks"
open fileRef
end
If you save this script as a script application or compiled script, rename the file "June Sales" or move it to another location, then run the script again, the script still works correctly and opens the original file.
You can coerce a filename string to an alias. For example, you can replace the first line of the previous script with the following line:
set fileRef to ("Hard Disk:June Sales" as alias)
However, you cannot perform a similar coercion with the file form, as described in Specifying a File by Reference.